package com.LeetCode;

import com.剑指offer.ListNode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class _21合并两个有序链表
{
    public static void main(String[] args)
    {
        System.out.println("多了一个输出");
    }

    public static ListNode mergeTwoLists(ListNode l1,ListNode l2){
        List<Integer> list = new ArrayList<>();
        while(l1 != null){
            list.add(l1.val);
            l1 = l1.next;
        }
        while(l2 != null){
            list.add(l2.val);
            l2 = l2.next;
        }
        Collections.sort(list);
        if(list.size() == 0)return null;
        ListNode p = new ListNode(list.get(0));
        ListNode q = p;
        for (int i = 1; i < list.size(); i++)
        {
            p.next = new ListNode(list.get(i));
            p = p.next;
        }
        return q;
    }
}
